#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <unistd.h>
pthread_t ntid;

void printids( const char *s)
{
    pid_t  pid;
    pthread_t tid;
    pid = getpid();
    tid  = pthread_self();
    printf( " %s    pid  %lu    tid     %lu   (0x%1x)\n",s,(unsigned long)pid,(unsigned long)tid,(unsigned long)tid);
}

void* thr_fn(void *arg)
{
    while(1)
    {
        printids("new thread :");
        usleep(200000);
    }
    
    return ((void *)0);
}

int main (int argc, char **argv )
{
    int err;
    //创建线程
    err = pthread_create(&ntid,NULL,thr_fn,NULL);
    if ( err != 0)
        perror(" can not create thread\n");
    sleep(1);
    printids("main thread:");
    
    //exit(0);
        
}